home *** CD-ROM | disk | FTP | other *** search
- /*
- "GridCopy.c" by Alexander M Kasprzyk
- ©1996
-
- This file is part of my CA toolkit. The GridCopy function
- allows very rapid copying from one location in memory
- to another, and was designed for use in Cellular Automata
- programs.
-
- Please feel free to contact me at:
- alex@kasprzyk.demon.co.uk
- */
-
- #include "GridCopyPr.h"
-
- // SetRBlockData - call to set the RBlockData structure
- void SetRBlockData( register Size gridSize, register RBlockDataPtr gridMove )
- {
- #ifdef powerc
- gridMove->ndouble = gridSize/8;
- gridSize -= gridMove->ndouble * 8;
- #endif
- gridMove->nlong = gridSize/4;
- gridSize -= gridMove->nlong * 4;
- gridMove->nshort = gridSize/2;
- gridSize -= gridMove->nshort * 2;
- gridMove->nchar = gridSize;
- }
-
- // RBlockMove - special block move call
- void RBlockMove( register Ptr srcPos, register Ptr dstPos, register RBlockDataPtr data )
- {
- register long count;
- #ifdef powerc
- for( count = 0; count < data->ndouble; count++ )
- *((double *)dstPos)++ = *((double *)srcPos)++;
- if( data->nlong )
- *((long *)dstPos)++ = *((long *)srcPos)++;
- #else
- for( count = 0; count < data->nlong; count++ )
- *((long *)dstPos)++ = *((long *)srcPos)++;
- #endif
- if( data->nshort )
- *((short *)dstPos)++ = *((short *)srcPos)++;
- if( data->nchar )
- *dstPos++ = *srcPos++;
- }